<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('user/admin_index/role',array('id'=>$row['user_id']))}">角色列表</a></li>
			<li class="active"><a>添加角色</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('user/admin_index/edit_role')}">
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>角色</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" value="{$role_list[$row.role]}" readonly>
				</div>
			</div>
			<div class="form-group" id="fempnumber">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>工号</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" value="{$row.fempnumber}" readonly>
				</div>
			</div>
			<div class="form-group" id="factory_id">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>组织</label>
				<div class="col-md-6 col-sm-10">
					<foreach name="factory_list" item="vo">
						<if $vo.id == $row.factory_id>
							<input type="text" class="form-control" value="{$vo.fname}" readonly>
						</if>
					</foreach>
				</div>
			</div>
			<div class="form-group" id="factory_id">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>业务员类型</label>
				<div class="col-md-6 col-sm-10">
					<label class="radio-inline">
						<input value="1" type="radio" name="type" <if $row.type == 1>checked</if> >内部业务员
					</label>
					<label class="radio-inline">
						<input value="2" type="radio" name="type" <if $row.type == 2>checked</if> >经销商
					</label>
				</div>
			</div>
			<div class="form-group" id="factory_id">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>预售功能</label>
				<div class="col-md-6 col-sm-10">
					<label class="checkbox-inline">
						<input value="1" type="checkbox" name="yushou" <if $row.yushou == 1>checked</if> >有
					</label>
				</div>
			</div>
			<div class="form-group" id="factory_id">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>发货工厂</label>
				<div class="col-md-6 col-sm-10">
					<foreach name="factory_list" item="vo">
						<if $vo.status == 1>
							<label class="checkbox-inline">
								<input value="{$vo.id}" type="checkbox" name="out_ids[]" <if in_array($vo.id,$row.out_ids)>checked</if> >{$vo.fname}
							</label>
						</if>
					</foreach>
					<p class="help-block">*发货工厂只与业务员有关</p>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="id" value="{$row.id}">
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
					<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
				</div>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script type="text/javascript">
	$('select[name=role]').change(function(){
		var role = $(this).val();
		console.log(role);
		if(role == 5){
			$('input[name=fempnumber]').val('');
			$('select[name=factory_id]').val('');
			$('#fempnumber').hide();
			$('#factory_id').hide();
		}else{
			$('#fempnumber').show();
			$('#factory_id').show();
		}
	});
	</script>
</body>
</html>